cmake_minimum_required(VERSION 3.5)
project(ch4_5_6)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}  -w  -O0 -march=native -g -std=c++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w   -O0 -march=native -g -std=c++11")

set(CMAKE_BUILD_TYPE "Release")

find_package(Eigen3 REQUIRED)
include_directories(
  ${EIGEN3_INCLUDE_DIR}
)

option(ENABLE_CERES "using ceres solver" ON)

if(ENABLE_CERES)
  find_package(Ceres REQUIRED)

  if (Ceres_FOUND)
      message(STATUS "Ceres-Solver Version: ${Ceres_VERSION}")
  endif()

  include_directories(${CERES_INCLUDE_DIRS})
  
  add_library(${PROJECT_NAME} SHARED
    read_data.cpp
	optimizer.cpp
	imu_integration.cpp
	pose_observe.cpp
	ceres_solver_optimize.cpp
	imu_factor.cpp
  )
  add_executable(main_ch5 main_ch5.cpp)
  target_link_libraries(main_ch5 ${PROJECT_NAME} 
  ${CERES_LIBRARIES}
  )
  add_executable(main_ch6 main_ch6.cpp)
  target_link_libraries(main_ch6 ${PROJECT_NAME} ${CERES_LIBRARIES})
else()
  add_library(${PROJECT_NAME} SHARED
    read_data.cpp
	optimizer.cpp
	imu_integration.cpp
	pose_observe.cpp
  )
  add_executable(main_ch5 main_ch5.cpp)
  target_link_libraries(main_ch5 ${PROJECT_NAME})
  add_executable(main_ch4 main_ch4.cpp)
  target_link_libraries(main_ch4 ${PROJECT_NAME})
endif()




